package com.example.onlinemusicserver2024.controller;

import com.example.onlinemusicserver2024.common.R;
import com.example.onlinemusicserver2024.model.domain.SongList;
import com.example.onlinemusicserver2024.service.SongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class SongListController {

    @Autowired
    SongListService songListService;

    @GetMapping("/songList")
    public R songList(@RequestParam(required = false) String style) {
        System.out.println("查询歌单列表：" + style);
        R result = songListService.songList(style);
        return result;
    }

    @PostMapping("/songList/update")
    public R songUpdate(@RequestBody SongList songList){
        System.out.println("更新歌单");
        R result = songListService.songUpdate(songList);
        return result;

    }

    /**
     * 根据风格查询歌单列表
     * @param style
     * @return
     */
    @GetMapping("/songList/style/detail")
    public R songListByStyle(@RequestParam String style) {
        System.out.println("查询歌单列表：" + style);
        R result = songListService.songListByStyle(style);
        return result;
    }

    /**
     * 根据歌单名称查询歌单列表
     * @param title
     * @return
     */
    @GetMapping("/songList/likeTitle/detail")
    public R songListByTitle(@RequestParam String title){
        R result = songListService.songListByTitle(title);
        return result;
    }

}
